package com.behome.socket_proxy;

import java.net.InetSocketAddress;
import java.net.Socket;

public class TcpClient {
    public boolean connectResult(String host,int port){
        boolean flag = true;
        try {
            Socket socket = new Socket();
            socket.connect(new InetSocketAddress(host, port), 1000);
            // 判断Socket连接状态
            if (socket.isConnected()) {
                flag =  true;
            } else {
                flag = false;
            }
            socket.setSoLinger(true, 0);
            socket.close();
            return flag;
        } catch (Exception e) {
            return false;
        }
    }
}
